Fitting GP to lightcurve 80_ra271.352_dec-29.642_MAXIJ1803 in Stan
Notebook outlining the fitting of GP to thunderKAT lightcurve 80_ra271.352_dec-29.642_MAXIJ1803.
1 Light Curve
- The light curve has \(N =\) 28 observations over a range of 198.79 days.
- Observations are evenly spread over the time range.
- The shortest gap between observations is 2.22 days.
- The longest gap between observations is 14.67 days.
- The mean flux density is \(\bar{y} =\) 0.0587 Jy.
- The mean standard error in the observations is 0.0000624 Jy.
- The observational noise is very small relative to the brightness of the observations.
2 SE Basic Model
- Zero constant mean function.
- Squared Exponential kernel function.
- Homoskedastic noise.
- Wide prior on observational noise, uninformed by observational noise estimates.
\[y \sim \mathcal{N}(f(x), \sigma_\textrm{noise}^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta^2 \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell^2}\right\}\]
\[\ell \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_\textrm{noise} \sim \mathcal{N}^+(0,1)\]
2.1 MCMC Results
variable mean median sd mad q5 q95 rhat
eta 0.06162 0.04861 0.04928 0.02055 0.02711 0.13266 1.00067
ell 164.05323 142.24100 85.46926 52.09634 83.40403 320.12535 1.00086
sigma 0.00155 0.00153 0.00023 0.00024 0.00121 0.00196 1.00239
ess_bulk ess_tail
2465 1562
2322 1841
2873 2447
2.2 MCMC Plots
2.3 Posterior Predictive Samples
The fitted model has a very long lengthscale, comparable to the length of the observational window. The estimated observational noise has a standard deviation is two orders of magnitude greater than that recorded in the original data. The combination of these parameters has lead to a very smooth fit that passes through the middle of the observed data points rather than through any datapoints themselves.
2.4 PSD
3 SE Observational Errors Model
- Zero constant mean function.
- Squared exponential kernel function.
- Heteroskedastic (Gaussian) noise.
- Incorporate data on error in observations of each \(y_i\).
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta^2 \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell^2}\right\}\]
\[\ell \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
3.1 MCMC Results
variable mean median sd mad q5 q95 rhat
eta 0.045350 0.044251 0.007867 0.007204 0.034750 0.059706 0.999626
ell 10.168749 10.187500 0.436035 0.420339 9.411075 10.853310 0.999804
sigma[1] 0.000086 0.000086 0.000009 0.000009 0.000072 0.000100 1.000408
ess_bulk ess_tail
4127 3038
4093 2572
4849 2893
3.2 MCMC Plots
3.3 Posterior Predictive Samples
By including the observed observational errors for setting priors on the Gaussian noise of each observation, the fitted median passes through each of the observed points.
3.4 PSD
4 SE Non-zero flat mean function Model
- Constant mean function, learned from observations.
- Weak prior on mean function intercept.
- Squared exponential kernel function.
- Heteroskedastic (Gaussian) noise.
- Incorporate data on error in observations of each \(y_i\).
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(C, k(x, x'))\]
\[C \sim \mathcal{U}[-1,1]\]
\[k(x,x') = \eta^2 \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell^2}\right\}\]
\[\ell \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
4.1 MCMC Results
variable mean median sd mad q5 q95 rhat
eta 0.001595 0.001569 0.000231 0.000226 0.001264 0.002006 0.999994
ell 0.978960 0.919284 0.358948 0.322083 0.512659 1.647210 1.000892
C 0.058665 0.058667 0.000313 0.000300 0.058149 0.059188 0.999833
sigma[1] 0.000086 0.000086 0.000009 0.000008 0.000071 0.000100 1.001164
ess_bulk ess_tail
5282 2601
5617 2842
3952 2478
5717 2777
4.2 MCMC Plots
4.3 Posterior Predictive Samples
4.4 PSD
5 SE Fixed constant mean function Model
- Constant mean function set at fixed value, e.g., mean of observations.
- Squared exponential kernel function.
- Heteroskedastic (Gaussian) noise.
- Incorporate data on error in observations of each \(y_i\).
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(C, k(x, x')),\quad C \in \mathbb{R}\]
\[k(x,x') = \eta^2 \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell^2}\right\}\]
\[\ell \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
5.1 Mean Function = 0.061
variable mean median sd mad q5 q95 rhat ess_bulk
eta 0.00291 0.00286 0.00040 0.00038 0.00235 0.00362 1.00174 5189
ell 1.29514 1.08483 0.75875 0.47578 0.55316 2.97471 1.00279 4867
sigma[1] 0.00009 0.00009 0.00001 0.00001 0.00007 0.00010 1.00105 5855
ess_tail
2379
2620
2817
5.2 Mean Function = 0.059
variable mean median sd mad q5 q95 rhat
eta 0.001608 0.001581 0.000231 0.000221 0.001278 0.002020 1.000380
ell 0.971589 0.911971 0.358267 0.319847 0.502400 1.644370 0.999937
sigma[1] 0.000086 0.000085 0.000009 0.000009 0.000071 0.000100 1.001193
ess_bulk ess_tail
6311 2673
5394 2855
6013 2649
5.3 Mean Function = 0.056
variable mean median sd mad q5 q95 rhat ess_bulk
eta 0.00319 0.00314 0.00044 0.00043 0.00255 0.00397 1.00035 6035
ell 1.38000 1.13118 0.81861 0.54967 0.55854 3.25948 1.00267 4442
sigma[1] 0.00009 0.00009 0.00001 0.00001 0.00007 0.00010 1.00250 5813
ess_tail
3143
3252
2901
6 Matern 3/2 kernel
- Matern 3/2 covariance kernel
- Zero constant mean function
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta^2 \left( 1 + \frac{\sqrt{3(x - x')^2}}{\ell}\right) \exp\left\{ -\frac{\sqrt{3(x - x')^2}}{\ell}\right\}\]
\[\ell \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
6.1 MCMC Results
variable mean median sd mad q5 q95 rhat
eta 0.048637 0.044109 0.021800 0.012371 0.029688 0.080836 1.000238
ell 60.439406 57.039200 17.662723 12.974381 40.831115 90.178535 1.000777
sigma[1] 0.000086 0.000086 0.000009 0.000009 0.000071 0.000100 1.000203
ess_bulk ess_tail
4058 2363
4186 2374
8834 2546
6.2 MCMC Plots
6.3 Posterior Predictive Samples
6.4 PSD
7 SE + Matern 3/2 additive kernel
- Sum of squared exponential and Matern 3/2 kernels
- single output scale (marginal variance) hyperparameter
- zero constant mean function
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta^2 \left[ \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell_\mathrm{SE}^2}\right\} + \left( 1 + \frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right) \exp\left\{ -\frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right\} \right]\]
\[\ell_\mathrm{SE} \sim \mathrm{InvGamma}(5,5)\]
\[\ell_\mathrm{M} \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
7.1 MCMC Results
variable mean median sd mad q5 q95 rhat
eta 0.00109 0.00086 0.00084 0.00045 0.00038 0.00246 1.00042
ell_SE 44.26588 37.72915 26.17904 14.15305 21.78390 87.93888 1.00209
ell_M 43.05689 41.35540 10.95611 9.51570 28.65622 62.88434 1.00089
sigma[1] 0.00009 0.00009 0.00001 0.00001 0.00007 0.00010 1.00117
ess_bulk ess_tail
4254 2429
4581 2554
4192 2537
8729 2493
7.2 MCMC Plots
7.3 Posterior Predictive Samples
7.4 PSD
8 SE + Matern 3/2 (2 output scales) additive kernel
- Sum of squared exponential and Matern 3/2 kernels
- One output scale (marginal variance) hyperparameter for each kernel
- zero constant mean function
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta_\textrm{SE}^2 \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell_\mathrm{SE}^2}\right\} + \eta^2_\textrm{M}\left( 1 + \frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right) \exp\left\{ -\frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right\}\]
\[\ell_\mathrm{SE} \sim \mathrm{InvGamma}(5,5)\]
\[\ell_\mathrm{M} \sim \mathrm{InvGamma}(5,5)\]
\[\eta_\textrm{SE} \sim \mathcal{N}^+(0,1)\]
\[\eta_\textrm{M} \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
8.1 MCMC Results
variable mean median sd mad q5 q95 rhat
eta_SE 0.00502 0.00000 0.03622 0.00000 0.00000 0.01485 1.52781
eta_M 0.00349 0.00120 0.02520 0.00177 0.00000 0.00964 1.52842
ell_SE 50.34066 1.06769 139.32085 0.53340 0.54951 242.32025 1.52828
ell_M 430.14665 365.39350 482.34979 334.13727 0.69897 1137.66900 1.52856
sigma[1] 0.00009 0.00009 0.00001 0.00001 0.00007 0.00010 0.99977
ess_bulk ess_tail
7 31
7 27
7 28
7 26
10254 5487
8.2 MCMC Plots
8.3 Posterior Predictive Samples
8.4 PSD
9 SE x Matern 3/2 multiplicative kernel
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta^2 \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell_\mathrm{SE}^2}\right\}\left( 1 + \frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right) \exp\left\{ -\frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right\}\]
\[\ell_\mathrm{SE} \sim \mathrm{InvGamma}(5,5)\]
\[\ell_\mathrm{M} \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
9.1 MCMC Results
variable mean median sd mad q5 q95
eta 0.002755 0.002114 0.002895 0.001097 0.000975 0.006462
ell_SE 57.783790 51.838600 25.568304 18.683873 30.500890 104.864100
ell_M 60.351649 57.814150 15.096787 12.721375 41.445750 88.143095
sigma[1] 0.000086 0.000086 0.000009 0.000009 0.000071 0.000100
f_star[1] 0.060711 0.060712 0.000092 0.000091 0.060559 0.060860
rhat ess_bulk ess_tail
1.000629 9063 4920
1.000249 8588 4476
1.000243 8519 5503
1.001430 11979 4810
0.999968 7345 7879
9.2 MCMC Plots
9.3 Posterior Predictive Samples
9.4 PSD
10 SE + Matern 3/2 + QP kernel
\[y_i \sim \mathcal{N}(f(x_i), \sigma_i^2)\]
\[f \sim \mathcal{GP}(\boldsymbol{0}, k(x, x'))\]
\[k(x,x') = \eta^2 \left[ \exp\left\{ -\frac{2 \sin^2\left( \pi\frac{\sqrt{(x - x')^2}}{T}\right)}{\ell_\mathrm{P}^2}\right\} + \exp\left\{ -\frac{1}{2}\frac{(x - x')^2}{\ell_\mathrm{SE}^2}\right\} + \left( 1 + \frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right) \exp\left\{ -\frac{\sqrt{3(x - x')^2}}{\ell_\mathrm{M}}\right\} \right]\]
\[\ell_\mathrm{P} \sim \mathrm{InvGamma}(5,5)\]
\[\ell_\mathrm{SE} \sim \mathrm{InvGamma}(5,5)\]
\[\ell_\mathrm{M} \sim \mathrm{InvGamma}(5,5)\]
\[\eta \sim \mathcal{N}^+(0,1)\]
\[T \sim \mathcal{U}[\textrm{minimum gap in x}, \textrm{range of x}]\]
\[\sigma_i \sim \mathcal{N}^+(\textrm{stderr}(y_i), \mathrm{Var}(\textrm{stderr}(\boldsymbol{y})))\]
10.1 MCMC Results
variable mean median sd mad q5 q95 rhat ess_bulk
eta 0.0004 0.0003 0.0002 0.0001 0.0001 0.0007 1.0082 6068
ell_SE 29.8219 26.0844 15.6114 9.3955 15.4976 53.6746 1.0136 298
ell_M 28.1432 27.4783 6.7953 6.2933 18.6478 39.9603 1.0051 2527
ell_P 2.3966 2.1037 1.2479 0.7938 1.1528 4.5984 1.0094 8752
T 135.9911 146.0825 48.0893 47.9465 37.6883 193.9104 1.0524 51
ess_tail
5788
4114
5610
4958
11